package com.example.keshe0337.biz;

import android.content.Context;

import com.example.keshe0337.dao.ParkingRecordDao;
import com.example.keshe0337.dao.ParkingSpaceDao;
import com.example.keshe0337.dao.RentDao;
import com.example.keshe0337.database.AppDatabase;
import com.example.keshe0337.entity.Rent;

import java.util.List;

public class RentService {
    private final RentDao rentDao;
    public RentService(Context context) {
        AppDatabase db = AppDatabase.getInstance(context);
        this.rentDao = db.rentDao();
    }


    public Rent selectRentByRId(Long rId) {
        return rentDao.getRentById(rId);
    }
    public int deleteRent(Long rId) {
        Rent rent = rentDao.getRentById(rId);
        if (rent != null) {
            rentDao.deleteRent(rent);
            return 0;
        }
        return 0;
    }

    public List<Rent> getAllRents() {
        return rentDao.getAllRents();
    }

    public List<Rent> getRentsByUid(Long uId) {
        return rentDao.getRentByUId(uId);
    }

    public List<Rent> getRentsByUidByNum(Long uId, String num) {
        return rentDao.getRentByUIdAndSum(uId,num);
    }
    public Rent getRentByNum(String num) {
        return rentDao.getRentBySum(num);
    }
}
